import java.awt.Graphics2D

import rpg.map.Location
import rpg.script.EffectScriptImpl
import rpg.visual.VisualImage

class EffectText extends EffectScriptImpl {
	
	// Use Events
	@Override
	public boolean onUse(Location location) {
		super.onUse(location);
	}
	
	@Override
	public boolean onPaint(Object context) {
		Graphics2D g = (Graphics2D) context;
		int percent = usePercent();
		
		String text = this.getEffect().getData().getName();
		int x = VisualImage.SQUARE_SIZE / 2 - g.getFontMetrics().stringWidth(text) / 2 + 12;
		int y = (100 - percent) * VisualImage.SQUARE_SIZE / 100 - 8; 
		
		g.setColor(this.getEffect().getColor());
		g.drawString(text, x, y);		
		return super.onPaint();
	}
}
